﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using 软件运行平台.ViewModel;

namespace 软件运行平台.View
{
    /// <summary>
    /// UserControl1.xaml 的交互逻辑
    /// </summary>
    public partial class MenuItemView : UserControl
    {

        MainWindow _context;
        public MenuItemView(MenuViewModel.MenuItem itemMenu, MainWindow context)
        {
            InitializeComponent();

            _context = context;
            ExpanderMenu.Visibility = itemMenu.SubItems == null ? Visibility.Collapsed : Visibility.Visible;
            ListViewItemMenu.Visibility = itemMenu.SubItems == null ? Visibility.Visible : Visibility.Collapsed;

            this.DataContext = itemMenu;
        }

        private void ListViewMenu_MouseUp(object sender, MouseButtonEventArgs e)
        {
            _context.SwitchScreen(((MenuViewModel.SubItem)((ListView)sender).SelectedItem).Screen);
        }
    }
    
}
